<?php if(!defined('HDPHP_PATH'))EXIT;
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."address`");
$db->exe("CREATE TABLE `".$db_prefix."address` (
  `aid` int(10) unsigned NOT NULL auto_increment,
  `name` char(15) NOT NULL default '' COMMENT '名字',
  `sex` enum('男','女') NOT NULL default '男' COMMENT '性别',
  `cellphone` char(11) NOT NULL COMMENT '手机号',
  `detail` varchar(65) NOT NULL default '' COMMENT '详细地址',
  `uid` int(10) unsigned NOT NULL,
  PRIMARY KEY  (`aid`),
  KEY `fk_gb_address_gb_user1_idx` (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='收货地址'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."columns`");
$db->exe("CREATE TABLE `".$db_prefix."columns` (
  `cnid` int(11) NOT NULL auto_increment,
  `pid` int(10) unsigned NOT NULL default '0',
  `title` varchar(45) NOT NULL default '' COMMENT '栏目标题',
  PRIMARY KEY  (`cnid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='栏目表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."comment`");
$db->exe("CREATE TABLE `".$db_prefix."comment` (
  `cid` int(11) NOT NULL auto_increment,
  `addtime` int(10) unsigned NOT NULL default '0' COMMENT '评论时间',
  `comments` text NOT NULL COMMENT '评论内容',
  `score` set('1','2','3','4','5') NOT NULL COMMENT '评分',
  `mealtime` char(3) NOT NULL default '' COMMENT '送餐花费的时间',
  `stid` int(10) unsigned NOT NULL,
  `sid` int(11) NOT NULL,
  `uid` int(10) unsigned NOT NULL,
  PRIMARY KEY  (`cid`),
  KEY `fk_comment_gb_store1_idx` (`stid`),
  KEY `fk_comment_gb_shop1_idx` (`sid`),
  KEY `fk_comment_gb_user1_idx` (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='评论'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."district`");
$db->exe("CREATE TABLE `".$db_prefix."district` (
  `did` int(11) NOT NULL auto_increment,
  `dname` varchar(45) NOT NULL default '',
  `ucwords` char(1) NOT NULL default '',
  `pid` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`did`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='地区'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."menu`");
$db->exe("CREATE TABLE `".$db_prefix."menu` (
  `mid` int(11) NOT NULL auto_increment,
  `menuname` char(10) NOT NULL default '' COMMENT '菜单名称',
  `stid` int(10) unsigned NOT NULL,
  PRIMARY KEY  (`mid`),
  KEY `fk_gb_menu_gb_store1_idx` (`stid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='菜单'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."order`");
$db->exe("CREATE TABLE `".$db_prefix."order` (
  `oid` int(11) NOT NULL auto_increment,
  `ordtime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '下单时间',
  `shopnub` smallint(5) unsigned NOT NULL default '0' COMMENT '商品数量',
  `Clearing` decimal(7,3) NOT NULL COMMENT '结算',
  `stid` int(10) unsigned NOT NULL COMMENT '商铺id',
  `uid` int(10) unsigned NOT NULL,
  `sid` int(11) NOT NULL,
  PRIMARY KEY  (`oid`),
  KEY `fk_gb_order_gb_store1_idx` (`stid`),
  KEY `fk_gb_order_gb_user1_idx` (`uid`),
  KEY `fk_gb_order_gb_shop1_idx` (`sid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='订单表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."shop`");
$db->exe("CREATE TABLE `".$db_prefix."shop` (
  `sid` int(11) NOT NULL auto_increment,
  `shopname` varchar(45) NOT NULL default '',
  `price` decimal(7,3) unsigned NOT NULL default '0.000' COMMENT '价格',
  `sell` smallint(5) unsigned NOT NULL default '0' COMMENT '出售数量',
  `recommend` smallint(5) unsigned NOT NULL default '0' COMMENT '推荐',
  `img` varchar(100) NOT NULL default '' COMMENT '商品图片',
  `mid` int(11) NOT NULL COMMENT '菜单ID',
  PRIMARY KEY  (`sid`),
  KEY `fk_gb_shop_gb_menu1_idx` (`mid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='商品表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."shopping`");
$db->exe("CREATE TABLE `".$db_prefix."shopping` (
  `spid` int(11) NOT NULL auto_increment,
  `shopnub` tinyint(3) unsigned NOT NULL default '0' COMMENT '商品数量',
  `sid` int(11) NOT NULL COMMENT '商品id',
  `stid` int(10) unsigned NOT NULL COMMENT '商铺id',
  `uid` int(10) unsigned NOT NULL,
  PRIMARY KEY  (`spid`),
  KEY `fk_shopping_gb_shop_idx` (`sid`),
  KEY `fk_shopping_gb_store1_idx` (`stid`),
  KEY `fk_shopping_gb_user1_idx` (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='购物车'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."store`");
$db->exe("CREATE TABLE `".$db_prefix."store` (
  `stid` int(10) unsigned NOT NULL auto_increment,
  `stname` varchar(45) NOT NULL default '' COMMENT '店铺名称',
  `thumb` varchar(100) NOT NULL default '' COMMENT '店铺缩略图',
  `kind` varchar(45) NOT NULL COMMENT '菜式种类',
  `bulletin` varchar(250) NOT NULL default '' COMMENT '店铺公告',
  `favorable` set('减','免','票') NOT NULL COMMENT '优惠名称(属性)',
  `delivery` decimal(7,3) NOT NULL default '0.000' COMMENT '配送价',
  `risedelivery` decimal(7,3) NOT NULL default '0.000' COMMENT '起送价',
  `metro` varchar(45) NOT NULL default '' COMMENT '地铁地址',
  `storesite` varchar(45) NOT NULL default '' COMMENT '商铺地址',
  `deliverytime` tinyint(3) unsigned NOT NULL default '0' COMMENT '平均配送时间',
  `sellnub` smallint(5) unsigned NOT NULL default '0' COMMENT '出售总数',
  `businessstart` int(2) unsigned NOT NULL default '0' COMMENT '营业时间开始',
  `businessend` int(2) unsigned NOT NULL default '0' COMMENT '营业结束时间',
  `cnid` int(11) NOT NULL default '0' COMMENT '栏目id',
  `district_did` int(11) NOT NULL default '0',
  PRIMARY KEY  (`stid`),
  KEY `fk_gb_store_Columns1_idx` (`cnid`),
  KEY `fk_gb_store_district1_idx` (`district_did`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='商铺'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."user`");
$db->exe("CREATE TABLE `".$db_prefix."user` (
  `uid` int(10) unsigned NOT NULL auto_increment COMMENT '用户id',
  `username` varchar(45) NOT NULL default '' COMMENT '用户名',
  `passwd` varchar(32) NOT NULL default '' COMMENT '用户密码',
  `is_admin` tinyint(1) unsigned NOT NULL default '0' COMMENT '是否后台用户',
  PRIMARY KEY  (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='用户表'");
